home *** CD-ROM | disk | FTP | other *** search
- /*
-
- To compare sorting times enable the code generation options profile.
- Add the profile library to the project and run as usual.
-
- Comparing the sorting time of each method to selection sort time we
- get the following results.
-
- Sort Method % Change
- =========== =========
- Selection 0%
- Shell -53.13%
- Bubble +126.24%
-
- What this means is, it takes the shell sort 53.13% less time to sort
- the same data as it does the selection sort. The bubble sort takes
- 126.24% more time.
-
- The reason for comparing the sorting times of the shell sort to the
- selection sort is the shell sort reduces to the selection sort when
- H is 1.
-
- */
-
-
- main()
- {
- char *elem, *el;
- int num;
-
- elem = "fdacbegzjmoqpzweyNQIOnπQiqyudgkeakcxhgasgshASjchAShKJWSKHGS°∏";
-
- num = strlen( elem );
- el = NewPtr((long)num+1);
- BlockMove(elem,el,(long)num+1);
-
- printf("BUBBL Before: %s\n",el);
- bubble(el,num);
- printf("BUBBL After: %s\n",el);
-
- BlockMove(elem,el,(long)num+1);
- printf("SHELL Before: %s\n",el);
- shell(el,num);
- printf("SHELL After: %s\n",el);
-
- BlockMove(elem,el,(long)num+1);
- printf("SELECT Before: %s\n",el);
- Selection(el,num);
- printf("SELECT After: %s\n",el);
-
- }
-
-